<template>
  <div>
    <el-container>
  <el-header>
    <div class="btnUnfold">
        <el-button type="primary" round @click="isCollapse = !isCollapse">展开</el-button>

    </div>
      <div class="userInfoHeader">
            <el-avatar icon="el-icon-user-solid" :src="data.avater"></el-avatar>
            <span>欢迎{{ data.name }} 权限：{{data.levelTitle}}</span>
      </div>
  </el-header>
  <el-container>
    <el-aside width=null>
      <el-row class="tac">
        <el-menu default-active="1-4-1"
        class="el-menu-vertical-demo"
        background-color="#545c64"
        text-color="#fff"
      active-text-color="#ffd04b"
      @open="handleOpen"
       @close="handleClose"
       :collapse="isCollapse">
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span slot="title">导航一</span>
              </template>
              <el-menu-item-group>
                <span slot="title">分组一</span>
                <el-menu-item index="1-1">选项1</el-menu-item>
                <el-menu-item index="1-2">选项2</el-menu-item>
              </el-menu-item-group>
              <el-menu-item-group title="分组2">
                <el-menu-item index="1-3">选项3</el-menu-item>
              </el-menu-item-group>
              <el-submenu index="1-4">
                <span slot="title">选项4</span>
                <el-menu-item index="1-4-1">选项1</el-menu-item>
              </el-submenu>
            </el-submenu>
            <el-menu-item index="2">
              <i class="el-icon-menu"></i>
              <span slot="title">导航二</span>
            </el-menu-item>
            <el-menu-item index="3" disabled>
              <i class="el-icon-document"></i>
              <span slot="title">导航三</span>
            </el-menu-item>
            <el-menu-item index="4">
              <i class="el-icon-setting"></i>
              <span slot="title">导航四</span>
            </el-menu-item>
        </el-menu>
      </el-row>
    </el-aside>
    <el-container>
      <el-main>
          <router-view />
      </el-main>
    </el-container>
  </el-container>
</el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isCollapse: true,
      data: '',
      userName: ''
    }
  },
  created() {
    console.log(this.$route)
    this.userName = this.$route.query.user
    // 获取用户信息
    this.$axios
      .post('api/useinfo', {
        params: {
          // username: 'admin',
          // passwold: '123'
          username: this.$route.query.user,
          token: this.pub.getToken(this.$route.query.user)
        }
      })
      .then((res) => {
        if (res.data.status === 0) {
          this.data = res.data.data
        }
        console.log(res, 'userinfo')
      })
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath)
    }
  }

}
</script>

<style lang='less'>
.el-row {
  height: calc(100vh - 60px);
  background-color: rgb(84, 92, 100);
}
.el-avatar {
  margin-top: 12px;
}
.el-container {
  height: calc(100vh - 60px);
}
.el-header{
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
  display:flex;
  .btnUnfold{
    flex: 1;
    text-align: left;
  }
  .userInfoHeader{
    flex:5;
    text-align: right;

  }
}

.el-aside {
  width: auto;
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  line-height: 160px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>
